<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>e.target</title>
</head>
<style>
    *{margin: 0;padding: 0;}
    body {
        width: 100vw;
        height: 100vh;
        background-color: slategrey;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .item-1 {
        width: 100px;
        height: 100px;
        background-color: violet;
        transform: translate(0,0);
    }
</style>
<body>
    <div class="item-1"></div>
    <div class="item-1"></div>
    <script>
        const item = document.querySelector('.item-1');

        let startX,startY,moveX,moveY,distanceX,distanceY;
        document.addEventListener('touchstart',(e) => {
            startX = e.targetTouches[0].clientX;
            startY = e.targetTouches[0].clientY;
            console.log(startX,startY)
        })

        document.addEventListener('touchmove',(e) => {
            moveX = e.targetTouches[0].clientX;
            moveY = e.targetTouches[0].clientY;
            console.log(moveX,moveY)
            distanceX = moveX - startX;
            distanceY = moveY - startY;
            // console.log(distanceX,distanceY)
            // 第二次拖拽时会出现回弹现象是因为translate移动的是差值
            e.target.style.transform = `translate(${distanceX}px,${distanceY}px)`
        })

       
    </script>
</body>
</html>